import { BaseEnum } from '@/enums/base'

/**
 * 血型枚举
 * 用于标识不同的血型类型
 */
export const BloodType = {
  /**
   * A型血
   */
  A: {
    code: "A",
    name: "A型",
    description: "A型血，可接受A型和O型血"
  },

  /**
   * B型血
   */
  B: {
    code: "B",
    name: "B型",
    description: "B型血，可接受B型和O型血"
  },

  /**
   * O型血
   */
  O: {
    code: "O",
    name: "O型",
    description: "O型血，万能献血者，只能接受O型血"
  },

  /**
   * AB型血
   */
  AB: {
    code: "AB",
    name: "AB型",
    description: "AB型血，万能受血者，可接受所有血型"
  },

  /**
   * 未知血型
   */
  Unknown: {
    code: "Unknown",
    name: "未知",
    description: "血型未知或未检测"
  },
} as const;

/**
 * 根据code获取枚举
 * @param code
 * @returns 枚举值或null
 */
export function matchCode(code: string): (typeof BloodType)[keyof typeof BloodType] | null {
  return (
    Object.values(BloodType).find((item) => item.code === code) || null
  );
}

/**
 * 获取所有血型选项
 * @returns 血型数组
 */
export function getBloodTypeOptions(): (typeof BloodType)[keyof typeof BloodType][] {
  return Object.values(BloodType);
}
